package infra

import (
	"gitee.com/hgslb/base"
	"github.com/gin-gonic/gin/binding"
)

func DoGetAliyun(qtype string, name string, sub string) (*HttpsDnsRsp, error) {
	q := make(map[string]string)
	q["name"] = name
	if sub != "" {
		q["edns_client_subnet"] = sub
	}
	if qtype != "" {
		q["type"] = qtype
	}

	buf, err := doGet(base.GslbConf.Dns.Https, q, nil)
	if err != nil {
		base.GslbLog.Infof("doGet failed:%s", err)
		return nil, err
	}
	rsp := &HttpsDnsRsp{}
	err = binding.JSON.BindBody(buf, rsp)
	if err != nil {
		base.GslbLog.Infof("BindBody failed:%s", err)
		return nil, err
	}
	return rsp, nil
}
